-
Notifications
You must be signed in to change notification settings - Fork 256
chore: fix cryptography warning #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| from cryptography.hazmat.primitives.padding import PKCS7 | ||
| from cryptography.hazmat.primitives.serialization import load_pem_private_key, load_pem_public_key | ||
| from cryptography.utils import int_from_bytes, int_to_bytes | ||
| from cryptography.utils import int_to_bytes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you can use int.from_bytes (it did not exist in 2.7), you can also use the to_bytes method of int.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but interestingly enough cryptography didn't bother to deprecate that one.
int_to_bytes is a custom implementation around int.to_bytes, so it's still needed.
Obviously this lifts the required python to 3.2+, but crypto itself has 3.6+ so this is necessary anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am facing the same issue.
d80c2d1 to
69bad89
Compare
|
I see tests are failed on 2.7. So conditional import is still needed. |
As I said above, |
69bad89 to
65446d9
Compare
|
Ok I have no idea what's going on with the CI. If it was about me, I would fix this simply by dropping support for python < 3.{3,6} for the whole project. |
setup.py
Outdated
| elif platform.python_implementation() == 'CPython' and platform.python_version() < '3.6': | ||
| return 'cryptography < 3.4' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is necessary.
Pip will resolve the correct version already based on cryptography's python_requires
$ python --version
Python 3.5.9
$ pip --version
pip 9.0.1
$ pip install python-jose[cryptography]
...
Installing collected packages: pyasn1, rsa, six, ecdsa, pycparser, cffi, cryptography, python-jose
Successfully installed cffi-1.14.5 cryptography-3.2.1 ecdsa-0.14.1 pyasn1-0.4.8 pycparser-2.20 python-jose-3.2.0 rsa-4.7 six-1.15.0
Note that on Python 3.5, even with an old version of pip, resolves cryptography to be 3.2.1 instead of 3.3.x or 3.4.x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see, good to know. I will drop this part then.
It looks like there's a typo in your import, where you import RSA is the fallback if both Fixing the typo should clear up the RSA error. |
| from cryptograph.utils import int_from_bytes, int_to_bytes | ||
| else: | ||
| from cryptograph.utils import int_to_bytes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| from cryptograph.utils import int_from_bytes, int_to_bytes | |
| else: | |
| from cryptograph.utils import int_to_bytes | |
| from cryptography.utils import int_from_bytes, int_to_bytes | |
| else: | |
| from cryptography.utils import int_to_bytes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, done :)
65446d9 to
0e3c4af
Compare
cryptography 3.4 was breaking change, so pin to minor version.
0e3c4af to
3fe3c82
Compare
Codecov Report
@@ Coverage Diff @@
## master #207 +/- ##
==========================================
- Coverage 93.51% 89.89% -3.63%
==========================================
Files 16 16
Lines 1728 1731 +3
==========================================
- Hits 1616 1556 -60
- Misses 112 175 +63
Continue to review full report at Codecov.
|
|
Alright so I don't see which parts are dropping in coverage because the codecov repo requires authentication. I strongly suggest to reconsider the decision to support anything < 3.6 and instead adopt #216 . If you decide to support anything lower than that, feel free to fix the dependency pinning as I'm not going to do that. |
|
@sbor23 |
|
Any updates on this PR? |
|
Any news? Also facing this issue in my app. |
|
@sbor23 look at failing tests in:
The other failing builds should be removed from Travis if the maintainers decided to drop support for Python 2.7 |
I know all of that and we're just waiting for maintainers to show up at that point. The CI is failing because of broken dependencies etc., as I mentiioned above. |
|
fixed in #229 Release coming very soon. |
|
When is this scheduled for released? It's quite a nuisance in our logs. |
It was released under 3.3.0. See #260 |
Fix a warning emitted by
cryptographysince a recent release.Edit:
The warning comes from cryptography 3.4 release. Since this release only python 3.6+ is supported.
This PR fixes the warning by using
int.from_bytes, which is only available since python 3.2.So obviously python 2.7 is not supported anymore cryptography.
So the solutions for python-jose are:
<3.4if python 2 is detected and make the imports conditional. Defining the deps a bit more strictly would make sense anyways.